package com.qfedu.yanglao20admin.health.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qfedu.yanglao20.entity.adhibition.Adhibition;
import com.qfedu.yanglao20admin.health.entity.HealthData;
import com.qfedu.yanglao20admin.health.dao.HealthDataDao;
import com.qfedu.yanglao20admin.health.service.HealthDataService;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * (HealthData)表服务实现类
 *
 * @author makejava
 * @since 2023-04-23 19:19:49
 */
@Service("healthDataService")
public class HealthDataServiceImpl implements HealthDataService {
    @Resource
    private HealthDataDao healthDataDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public HealthData queryById(Integer id) {
        return this.healthDataDao.queryById(id);
    }


    /**
     * 修改数据
     *
     * @param healthData 实例对象
     * @return 实例对象
     */
    @Override
    public HealthData update(HealthData healthData) {
        this.healthDataDao.update(healthData);
        return this.queryById(healthData.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.healthDataDao.deleteById(id) > 0;
    }

    /**
     * 分页查询应用服务信息
     *
     * @param param
     * @return
     */
    @Override
    public Page<HealthData> pageHealthdata(com.qfedu.yanglao20admin.health.param.HealthData param) {
        // 分页查询
        Page<HealthData> page = new Page<>(param.getPageNum(), param.getPageSize());
        List<HealthData> healthData = healthDataDao.selectList(param);

        // 页码
        page.setCurrent(param.getPageNum());
        page.setSize(param.getPageSize());

        page.setRecords(healthData);

        return page;
    }
}
